<?php
/* -------------------------------------------------------------------------------------
* 	ID:						$Id: orders_pdf_profiler.php 84 2013-09-21 12:03:13Z phone.mueller@googlemail.com $
* 	Letzter Stand:			$Revision: 84 $
* 	zuletzt geaendert von:	$Author: siekiera $
* 	Datum:					$Date: 2013-09-21 12:03:13 +0000 (Sat, 21 Sep 2013) $
*
* 	SEO:mercari by Siekiera Media
* 	http://www.seo-mercari.de
*
* 	Copyright (c) since 2011 SEO:mercari
* --------------------------------------------------------------------------------------
* 	based on:
* 	(c) 2000-2001 The Exchange Project  (earlier name of osCommerce)
* 	(c) 2002-2003 osCommerce - www.oscommerce.com
* 	(c) 2003     nextcommerce - www.nextcommerce.org
* 	(c) 2005     xt:Commerce - www.xt-commerce.com
*
* 	Released under the GNU General Public License
* ----------------------------------------------------------------------------------- */

require('includes/application_top.php');

if ($_GET['action']) {
	switch ($_GET['action']) {
		case 'save':
			$pdf_save = $db->db_query("SELECT
											pdf_key,
											pdf_value
										FROM
											".TABLE_ORDERS_PDF_PROFILE."
										WHERE
											languages_id = '".(int)$_POST['language_id']."'");
			while(!$pdf_save->EOF) {
				$db->db_query("UPDATE ".TABLE_ORDERS_PDF_PROFILE." SET pdf_value = '".$_POST[$pdf_save->fields['pdf_key']]."' WHERE pdf_key = '".$pdf_save->fields['pdf_key']."' AND languages_id = '".(int)$_POST['language_id']."' ");
				$pdf_save->MoveNext();
			}
			redirect(href_link('orders_pdf_profiler.php'));
	    break;

	}
}
require(DIR_WS_INCLUDES.'metatag.php');
?>
<script type="text/javascript">
<!--
	$(function(){
		$('#tabs').tabs({fx:{ opacity:'toggle'} });
		$("textarea").TextAreaExpander();
	});
//-->
</script>
</head>
<body>
<?php require(DIR_WS_INCLUDES.'header.php'); ?>
<div id="wrapper">
	<table class="outerTable" cellspacing="0" cellpadding="0">
		<tr>
			<td class="columnLeft2" width="<?php echo BOX_WIDTH; ?>" valign="top">
				<?php require(DIR_WS_INCLUDES.'column_left.php'); ?>
			</td>
			<td valign="top" class="boxCenter">
	        	<table class="table_pageHeading" border="0" width="100%" cellspacing="0" cellpadding="0">
		   			<tr>
		     			<td class="pageHeading">PDF Konfigurator f&uuml;r Rechnung und Lieferschein</td>
					</tr>
				</table>
				<div id="tabs">
					<ul>
						<?php
							$languages_link = get_languages();
							for ($i = 0; $i < sizeof($languages_link); $i++) { ?>
							<li><a href="#language_<?php echo $languages_link[$i]['id']; ?>" onclick="return false;">
									<span><img src="../lang/<?php echo $languages_link[$i]['directory'].'/'.$languages[$i]['image']; ?>" alt="" /> <?php echo $languages_link[$i]['name'] ?></span>
								</a>
							</li>
						<?php } ?>
					</ul>
					<?php
					$languages_content = get_languages();
					for ($ii = 0; $ii < sizeof($languages_content); $ii++) { ?>
						<div id="language_<?php echo $languages_content[$ii]['id'] ?>">
							<?php echo draw_form('orders_pdf_profiler', 'orders_pdf_profiler.php', 'action=save'); ?>
					        	<table width="100%" height="100%" valign="top" cellpadding="4">
					        		<?php
					        			$pdf = $db->db_query("SELECT * FROM ".TABLE_ORDERS_PDF_PROFILE." WHERE languages_id = '".$languages_content[$ii]['id']."' ");
					        			while(!$pdf->EOF) { $i++;
					        				if($pdf->fields['type'] == 'textarea')
					        					$field = '<textarea row="" cols="" name="'.$pdf->fields['pdf_key'].'" class="resizable">'.$pdf->fields['pdf_value'].'</textarea>';
					        				elseif($pdf->fields['type'] == 'input')
					        					$field = '<input type="text" name="'.$pdf->fields['pdf_key'].'" value="'.$pdf->fields['pdf_value'].'" style="width:90%" />';
					        				if ($i % 2 == 0) $f = '';
									    	else $f = ' class="dataTableRow"';
										   echo '<tr'.$f.'>
					        						<td width="40%" valign="top"><b>'.constant(strtoupper($pdf->fields['pdf_key'].'_TITLE')).'<b/></td>
					        						<td valign="top">'.$field.'<br />'.constant(strtoupper($pdf->fields['pdf_key'].'_DESC')).'<br /><br /></td>
					        					</tr>';
										   $pdf->MoveNext();
					        			}
					        		?>
					        		<tr>
				      					<td align="right" colspan="2">
					    					<input type="submit" class="button" onClick="this.blur();" value="<?php echo BUTTON_SAVE ?>"/>
					    				</td>
				      				</tr>
					        	</table>
					        	<input type="hidden" name="language_id" value="<?php echo $languages_content[$ii]['id'] ?>" />
					        </form>
				        </div>
		        	<?php } ?>
		        </div>
		    </td>
		</tr>
	</table>
</div>
<?php require(DIR_WS_INCLUDES.'footer.php'); ?>
</body>
</html>
<?php require(DIR_WS_INCLUDES.'application_bottom.php'); ?>